/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jBeatsAddSongtoPlaylist.java
 *
 * Created on Dec 5, 2012, 4:14:32 PM
 */
package cs341.cs.uwosh.edu.jBeats;

/**
 *
 * @author macnaj20
 */
public class jBeatsAddSongtoPlaylist extends javax.swing.JFrame {
    String userName;
    int songKey;
    String songName;
    /** Creates new form jBeatsAddSongtoPlaylist */
    public jBeatsAddSongtoPlaylist(int song, String songname, String user) {
        initComponents();
        this.songName = songname;
        System.out.println(songName);
        addToPlaylistSongName.setText(songName);
        this.userName = user;
        this.songKey = song;
        
        addToPlayListComboBox.setModel(new javax.swing.DefaultComboBoxModel(DatabaseInfo.getPlaylists(userName)));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        addToPlayListComboBox = new javax.swing.JComboBox();
        addToPlaylistAddButton = new javax.swing.JButton();
        addToPlaylistSongName = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(84, 131, 161));
        jPanel1.setName("jPanel1"); // NOI18N

        addToPlayListComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        addToPlayListComboBox.setName("addToPlayListComboBox"); // NOI18N

        addToPlaylistAddButton.setText("Add Song To Playlist");
        addToPlaylistAddButton.setName("addToPlaylistAddButton"); // NOI18N
        addToPlaylistAddButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addToPlaylistAddButtonActionPerformed(evt);
            }
        });

        addToPlaylistSongName.setText("item");
        addToPlaylistSongName.setName("addToPlaylistSongName"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(addToPlaylistSongName)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(addToPlaylistAddButton)
                        .addComponent(addToPlayListComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(49, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addComponent(addToPlaylistSongName)
                .addGap(18, 18, 18)
                .addComponent(addToPlayListComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(addToPlaylistAddButton)
                .addGap(25, 25, 25))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void addToPlaylistAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToPlaylistAddButtonActionPerformed
    DatabaseInfo.addPlaylistSong(userName, (String)addToPlayListComboBox.getSelectedItem(), songKey);
    this.dispose();
}//GEN-LAST:event_addToPlaylistAddButtonActionPerformed

    /**
     * @param args the command line arguments
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox addToPlayListComboBox;
    private javax.swing.JButton addToPlaylistAddButton;
    private javax.swing.JLabel addToPlaylistSongName;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
